using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerBlackHoleState : PlayerState
{
    private float flyTime=0.4f;
    private bool skillUsed;
    private float defaultgravity;

    public PlayerBlackHoleState(Player player, StateMachine stateMachine, string animName) : base(player, stateMachine, animName)
    {
    }


    public override void Enter()
    {
        base.Enter();
        defaultgravity = rb.gravityScale;
        stateTimer = flyTime;
        skillUsed = false;
        rb.gravityScale = 0;
        cc.enabled = false;
        AudioManager.Instance.PlaySound((int)E_SoundType.BanKai);
    }


    public override void Update()
    {
        base.Update();
        if (stateTimer > 0)
        {
            rb.velocity = new Vector2(0, 15);
        }
        else
        {
            rb.velocity = new Vector2(0, -0.1f);
            if (!skillUsed)
            {
                player.skill.blackHole.UseSkill();
                skillUsed = true;
            }
        }
    }

    public override void Exit()
    {
        base.Exit();
        rb.gravityScale = defaultgravity;
        cc.enabled = true;
    }
}
